
#include "../header.h"

//独立 + 并发 + 异步 + 动态

//输出顺序：优先级 + 抢占 + 时间片轮转 - 并发属性
//父进程先输出:1 2 1 3 4 4
//子进程抢占先输出:1 3 4 1 2 4 
int main(int argc, char const *argv[])
{
    pid_t pid = fork();
    printf("test1\n");
    if(pid < 0)
    {
        perror("fork error\n");
        return -1;
    }
    if(pid > 0 )
    {
        printf("test2\n");
        printf("this is parents process:%d\n",getpid());
        //避免孤儿进程
        sleep(1);
    }
    if(pid == 0)
    {
        printf("test3\n");
        printf("this is child process:%d\n",getpid());
    }
    printf("test4\n");
    return 0;
}
